| Total Complexity | 6 | 
| Total Lines | 31 | 
| Duplicated Lines | 0 % | 
| Changes | 0 | ||
| 1 | import {Task} from 'src/Domain/Task/Task.entity'; | 
            ||
| 7 | |||
| 8 | export abstract class AbstractProjectAndTaskGetter { | 
            ||
| 9 | constructor(  | 
            ||
| 10 | private readonly taskRepository: ITaskRepository,  | 
            ||
| 11 | private readonly projectRepository: IProjectRepository  | 
            ||
| 12 |   ) {} | 
            ||
| 13 | |||
| 14 |   protected async getTask(taskId?: string): Promise<Task | null> { | 
            ||
| 15 |     if (!taskId) { | 
            ||
| 16 | return null;  | 
            ||
| 17 | }  | 
            ||
| 18 | |||
| 19 | const task = await this.taskRepository.findOneById(taskId);  | 
            ||
| 20 |     if (!task) { | 
            ||
| 21 | throw new TaskNotFoundException();  | 
            ||
| 22 | }  | 
            ||
| 23 | |||
| 24 | return task;  | 
            ||
| 25 | }  | 
            ||
| 26 | |||
| 27 |   protected async getProject(projectId?: string): Promise<Project | null> { | 
            ||
| 28 |     if (!projectId) { | 
            ||
| 29 | return null;  | 
            ||
| 30 | }  | 
            ||
| 31 | |||
| 32 | const project = await this.projectRepository.findOneById(projectId);  | 
            ||
| 33 |     if (!project) { | 
            ||
| 34 | throw new ProjectNotFoundException();  | 
            ||
| 35 | }  | 
            ||
| 36 | |||
| 37 | return project;  | 
            ||
| 38 | }  | 
            ||
| 40 |